home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / avwyyt1a / cmouse.cls < prev    next >
Text File  |  1999-08-29  |  2KB  |  57 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CMouse"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
  15. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  16. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  17. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
  18.  
  19. Private Type POINTAPI
  20.     X As Long
  21.     Y As Long
  22. End Type
  23.  
  24. Property Get X() As Single
  25.     Dim tmpPnt As POINTAPI
  26.     GetCursorPos tmpPnt
  27.     X = CSng(tmpPnt.X)
  28. End Property
  29.  
  30. Property Let X(ByVal New_X As Single)
  31.     Dim tmpPnt As POINTAPI
  32.     GetCursorPos tmpPnt
  33.     SetCursorPos CLng(New_X), tmpPnt.Y
  34. End Property
  35.  
  36. Property Get Y() As Single
  37.     Dim tmpPnt As POINTAPI
  38.     GetCursorPos tmpPnt
  39.     Y = tmpPnt.Y
  40. End Property
  41.  
  42. Property Let Y(ByVal New_Y As Single)
  43.     Dim tmpPnt As POINTAPI
  44.     GetCursorPos tmpPnt
  45.     SetCursorPos tmpPnt.X, CLng(New_Y)
  46. End Property
  47.  
  48. Function WindowOver(ByVal X As Single, ByVal Y As Single) As String
  49.     Dim sBuffer As String * 255, sLen As Long
  50.     sLen = GetWindowText(WindowFromPoint(CLng(X), CLng(Y)), sBuffer, 255)
  51.     WindowOver = Left$(sBuffer, sLen)
  52. End Function
  53.  
  54. Private Sub Class_Initialize()
  55.  
  56. End Sub
  57.